//
//  LXDIsSingerTableViewCell.m
//  BLDMusics
//
//  Created by lxd on 16/4/4.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "LXDIsSingerTableViewCell.h"

@interface LXDIsSingerTableViewCell ()

@property (nonatomic, retain) UIImageView *picImage;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *descLabel;
@property (nonatomic, retain) UILabel *timeLabel;

@end



@implementation LXDIsSingerTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createControls];
    }
    return self;
}


- (void)createControls {
    
    self.picImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_picImage];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    
    self.descLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_descLabel];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_timeLabel];
    
    
}


- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [_picImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
//        // 距左10
//        make.left.mas_equalTo(self.contentView).with.offset(10);
//        // 距右10
//        make.right.equalTo(self.contentView).with.offset(-10);
//        // 距上10
//        make.top.equalTo(self.contentView).with.offset(10);
//        // 距下
//        make.bottom.equalTo(self.contentView).with.offset(-35);
        
        make.edges.equalTo(self.contentView).with.insets(UIEdgeInsetsMake(10, 10, 60, 10));

    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_picImage.mas_bottom).with.offset(5);
        make.left.equalTo(self.contentView).with.offset(10);
        make.right.equalTo(self.contentView).with.offset(-100);
        make.height.equalTo(@20);
    }];

    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).with.offset(5);
        make.left.equalTo(self.contentView).with.offset(10);
        make.right.equalTo(self.contentView).with.offset(-10);
        make.height.equalTo(@15);
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_picImage.mas_bottom).with.offset(5);
        make.right.equalTo(self.contentView).with.offset(-10);
        make.height.equalTo(@20);
        make.width.equalTo(@80);
    }];
    
    _descLabel.font = [UIFont systemFontOfSize:13];
    _timeLabel.font = [UIFont systemFontOfSize:12.5];
    _timeLabel.textColor = [UIColor grayColor];
    _descLabel.textColor = [UIColor darkGrayColor];
}

- (void)setModel:(LXDIsSingerModel *)model {
    if (_model != model) {
        _model = model;
        [_picImage sd_setImageWithURL:[NSURL URLWithString:_model.picUrl]];
        _titleLabel.text = _model.name;
        _descLabel.text = _model.desc;
        _timeLabel.text = _model.date;
    }
}

@end
